package com.dragon.datastructure.tree.trie;


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;

/**
 * @author dragon
 * @since 2020/1/2
 */
public class TrieTest {

    public static void main(String[] args) throws Exception {
        Trie trie = new Trie();
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File("/Users/panlong/Downloads/b")));
        byte[] array = new byte[1024];
        int ch;
        StringBuilder sb = new StringBuilder();
        while ((ch = bis.read(array)) != -1) {
            sb.append(new String(array, 0, ch));
        }
        bis.close();
        String[] words = sb.toString().split(" ");
        for (String word : words) {
//            trie.add(word);
            trie.addCur(word);
        }
        System.out.println("NullPointerException:" + trie.contains("NullPointerException"));
        System.out.println("trie是否包含exception:" + trie.contains("exception"));

        System.out.println("Null是前缀吗:" + trie.isPrefix("Null"));


    }
}
